<%@page import="com.baoyanghui.common.Constants"%>
<%@page import="com.baoyanghui.config.Configs"%>
<%@page import="com.baoyanghui.common.Utils"%>
<%@page import="com.baoyanghui.common.InterfaceAccess"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	if (Utils.empty((String)request.getSession().getAttribute(Configs.SESSION_USER_ID))
			|| (Constants.USER_TYPE_CUSTOMER == (Integer)request.getSession().getAttribute(Configs.SESSION_USER_TYPE))) {
		response.getWriter().print("<script type='text/javascript'>\n");
		response.getWriter().print("window.location.href='" + request.getContextPath() + "/index.jsp';\n");
		response.getWriter().print("</script>\n");
		response.getWriter().flush();
		return;
	}
%>
<script type="text/javascript">
function changePwd() {
	var password = $("#password").val();
	var new_password = $("#new_password").val();
	var confirm_password = $("#confirm_password").val();
	var pattern = /[a-zA-Z0-9]{4,20}/;
	
	if (password == "" || !pattern.test(password)) {
		$("#error_message").html("密码错误<br/>");
		$("#password").css("background", "#fbe2e2");
		return;
	} else {
		$("#error_message").html("");
		$("#password").css("background", "#ffffff");
	}
	
	if (new_password == "" || !pattern.test(new_password)) {
		$("#error_message").html("新密码错误<br/>");
		$("#new_password").css("background", "#fbe2e2");
		return;
	} else {
		$("#error_message").html("");
		$("#new_password").css("background", "#ffffff");
	}
	
	if (confirm_password != new_password) {
		$("#error_message").html("确认密码错误<br/>");
		$("#confirm_password").css("background", "#fbe2e2");
		return;
	} else {
		$("#error_message").html("");
		$("#confirm_password").css("background", "#ffffff");
	}

	$.post("change_pwd", {password:password,new_password:new_password}, function(data){
		alert(data);
	}, "json");
}
</script>
<div style="height: 34px; padding-left: 20px; padding-top: 5px; border-bottom: 1px solid gray;">
	<img class="pointer fade_effect" src="../image/btn_basic_info_on.png"/>
	<img class="pointer fade_effect" src="../image/btn_place_request_auth_off.png"/>
</div>
<div style="padding: 15px;">
	<h2>设置您的密码</h2>
	<form>
		<div align="left" style="padding-left: 250px; line-height: 50px;">
			<label>当前密码：</label><input type="password" name="password" id="password" maxlength="20"/><br/>
			<label>新密码：</label><input type="password" name="new_password" id="new_password" maxlength="20"/>
			<span>（字母或数字,至少6个字符）</span><br/>
			<label>确认密码：</label><input type="password" name="confirm_password" id="confirm_password" maxlength="20"/><br/>
		</div>
		<div align="center" style="padding-top: 45px;">
			<img src="<%= request.getContextPath()%>/image/btn_change_pwd.png" class="pointer fade_effect"
				onclick="changePwd();"/>
			<img src="<%= request.getContextPath()%>/image/btn_cancel.png" class="pointer fade_effect"
				style="margin-left: 70px;" onclick="exitChangePwd();"/>
			<span id="error_message"></span>
		</div>
	</form>
</div>